package com.hxx.common.core.wcontour.db;

import lombok.Data;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.postgis.PostgisNGDataStoreFactory;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * PostgreSql 数据库
 * @author hxd
 */
@Data
public class PgDataStore {

    private String host;
    private String port;
    private String dbname;
    private String schema;
    private String username;
    private String password;

    public static DataStore getDatastore() {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(PostgisNGDataStoreFactory.DBTYPE.key, "postgis");
        params.put(PostgisNGDataStoreFactory.HOST.key, "192.168.1.43");
        params.put(PostgisNGDataStoreFactory.PORT.key, 5413);
        params.put(PostgisNGDataStoreFactory.DATABASE.key, "l3a1");
        params.put(PostgisNGDataStoreFactory.SCHEMA.key, "public");
        params.put(PostgisNGDataStoreFactory.USER.key, "postgres");
        params.put(PostgisNGDataStoreFactory.PASSWD.key, "postgis_13");
        DataStore dataStore = null;
        try {
            dataStore = DataStoreFinder.getDataStore(params);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return dataStore;
    }

}